import http from './axios'

function curd(root) {
	this.root = '/' + root + '/';
	
	this.query = (params) => {
		return http.get(root, {
			params: params
		});
	};

	this.list = (params) => {
		return http.get(this.root + 'list', {
			params: params
		});
	};

	this.queryById = (id) => {
		return http.get(this.root + id);
	};

	this.add = (params) => {
		return http.post(this.root, params);
	};

	this.update = (params) => {
		return http.put(this.root, params);
	};

	this.delete = (id) => {
		return http.delete(this.root + id);
	};

	this.batchDelete = (ids) => {
		return http.delete(this.root, {
			data: ids
		});
	};

}

export default curd;
